package com.kj.xuyuan.adapter;

import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.kj.xuyuan.R;
import com.kj.xuyuan.http.UrlConstants;
import com.kj.xuyuan.model.InviteBean;
import com.kj.xuyuan.util.GlideUtils;

import java.util.List;

import androidx.annotation.Nullable;

public class InviteRankingAdapter extends BaseQuickAdapter<InviteBean.ListBean, BaseViewHolder> {
    public InviteRankingAdapter() {
        super(R.layout.item_invite_ranking);
    }

    @Override
    protected void convert(BaseViewHolder helper, InviteBean.ListBean item) {
        ImageView ivHead = helper.getView(R.id.iv_head);
        GlideUtils.loadCircleImage(mContext, UrlConstants.Base_Http+item.getUserinfo().getAvatar(),ivHead);
        helper.setText(R.id.tv_name,item.getUserinfo().getNickname());
        helper.setText(R.id.tv_jiangli,"+"+item.getSum());
        helper.setText(R.id.tv_invite_num,"已邀请"+item.getInvite_num()+"人");

        ImageView ivRanking = helper.getView(R.id.iv_ranking);
        TextView tvRanking = helper.getView(R.id.tv_ranking);
        if(helper.getLayoutPosition()>1){
            tvRanking.setVisibility(View.VISIBLE);
            ivRanking.setVisibility(View.GONE);
            tvRanking.setText(helper.getLayoutPosition()+1+"");
        }else if(helper.getLayoutPosition() == 0){
            tvRanking.setVisibility(View.GONE);
            ivRanking.setVisibility(View.VISIBLE);
            ivRanking.setImageResource(R.mipmap.icon_invite_top_one);
        }else{
            tvRanking.setVisibility(View.GONE);
            ivRanking.setVisibility(View.VISIBLE);
            ivRanking.setImageResource(R.mipmap.icon_invite_top_two);
        }
    }
}
